package com.ciwong.epaper.modules.clazz.adapter;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.ciwong.epaper.R;
import com.ciwong.epaper.modules.clazz.bean.TeacherClassBean;
import com.ciwong.epaper.modules.epaper.util.EpaperJumpManager;
import com.ciwong.epaper.util.RequestCode;
import com.ciwong.mobilelib.i.ViewOnClickListener;

import java.util.ArrayList;
import java.util.List;

public class TeacherClassAdapter extends BaseAdapter {

    private Context mContext;
    private RelativeLayout tea_class_lay_child;
    private TextView class_name;
    private TextView class_member_count;
    private RelativeLayout student_work_report_lay;
    private RelativeLayout home_work_report_lay;
    private RelativeLayout computer_room_test_report_lay;
    private RelativeLayout classroom_teaching_report_lay;
    private List<TeacherClassBean> teacherClassBeans = new ArrayList<>();
    private String clientId;
    private int classId;

    public TeacherClassAdapter(Activity context, List<TeacherClassBean> teacherClassBeans, String clientId) {
        this.mContext = context;
        this.teacherClassBeans = teacherClassBeans;
        this.clientId = clientId;
    }

    @Override
    public int getCount() {
        return teacherClassBeans == null ? 0 : teacherClassBeans.size();
    }

    @Override
    public Object getItem(int i) {
        return teacherClassBeans == null ? null : teacherClassBeans.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(final int i, View view, ViewGroup viewGroup) {
        if (null == view) {
            view = LayoutInflater.from(mContext).inflate(R.layout.activity_tea_class_child, viewGroup, false);
        }
        class_name = view.findViewById(R.id.class_name);
        class_member_count = view.findViewById(R.id.class_member_count);
        tea_class_lay_child = view.findViewById(R.id.tea_class_lay_child);
        student_work_report_lay = view.findViewById(R.id.student_work_report_lay);
        home_work_report_lay = view.findViewById(R.id.home_work_report_lay);
        computer_room_test_report_lay = view.findViewById(R.id.computer_room_test_report_lay);
        classroom_teaching_report_lay = view.findViewById(R.id.classroom_teaching_report_lay);
        class_name.setText(teacherClassBeans.get(i).getClassName());
        class_member_count.setText("学生: " + teacherClassBeans.get(i).getStudentSize() + "人" + "  " + "vip:" + teacherClassBeans.get(i).getVipCount() + "人");
        classId = teacherClassBeans.get(i).getClassId();

        student_work_report_lay.setOnClickListener(new ViewOnClickListener() {
            @Override
            public void avertRepeatOnClick(View v) {
                EpaperJumpManager.jumpToWorkReport((Activity) mContext, R.string.go_back, teacherClassBeans.get(i).getClassId() + "", teacherClassBeans.get(i).getClassName(), RequestCode.TeaWorkContent.WORK_STATISTICS_REPORT);
            }
        });
        home_work_report_lay.setOnClickListener(new ViewOnClickListener() {
            @Override
            public void avertRepeatOnClick(View v) {
                EpaperJumpManager.jumpToWorkReport((Activity) mContext, R.string.go_back, teacherClassBeans.get(i).getClassId() + "", teacherClassBeans.get(i).getClassName(), RequestCode.TeaWorkContent.WORK_LISTENSPEAK_REPORT);
            }
        });
        computer_room_test_report_lay.setOnClickListener(new ViewOnClickListener() {
            @Override
            public void avertRepeatOnClick(View v) {
                EpaperJumpManager.jumpToWorkReport((Activity) mContext, R.string.go_back, teacherClassBeans.get(i).getClassId() + "", teacherClassBeans.get(i).getClassName(), RequestCode.TeaWorkContent.WORK_EXAM_ROOM_REPORT);
            }
        });
        classroom_teaching_report_lay.setOnClickListener(new ViewOnClickListener() {
            @Override
            public void avertRepeatOnClick(View v) {
                EpaperJumpManager.jumpToWorkReport((Activity) mContext, R.string.go_back, teacherClassBeans.get(i).getClassId() + "", teacherClassBeans.get(i).getClassName(), RequestCode.TeaWorkContent.CLASS_WORK);
            }
        });
        return view;
    }

    public void setClick() {

    }
}
